package lambdaDemo;

/**
 * Lambda () -> {}
 * 
 * 使用前提：
 * 有一个接口
 * 接口中有且仅有一个抽象方法
 */

public class Demo {
  public static void main(String[] args) {
    goSwimming(new Swimming() {
      @Override
      public void swim() {
        System.out.println("去游泳");
      }
    });

    goSwimming(() -> {
      System.out.println("lambda 去游泳");
    });
  }

  public static void goSwimming(Swimming swimming) {
    swimming.swim();
  }
}

interface Swimming {
  void swim();
}
